import wx

class MyFrame(wx.Frame):
    def __init__(self, parent, title):
        super(MyFrame, self).__init__(parent, -1, title, size=(300, 200))

        self.timer = wx.Timer(self)
        self.Bind(wx.EVT_TIMER, self.OnTimer, self.timer)
        self.timer.Start(1000)

    def OnTimer(self, event):
        print("定时器事件触发")


app = wx.App(False)
frame = MyFrame(None, 'wx.timer示例')
frame.Show()
app.MainLoop()
